﻿using Kingdee.BOS.Core.CommonFilter.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LiMinCRMPlugin
{
    /// <summary>

    /// 【过滤插件】账表过滤窗体上查询基础资料时设置过滤条件

    /// </summary>

    [Description("【过滤插件】账表过滤窗体上查询基础资料时设置过滤条件"), HotUpdate]

    public class RawMaterialInventoryFilter : AbstractCommonFilterPlugIn

    {

        /// <summary>

        /// 基础资料查询前事件，账表过滤窗体上的快捷页签中的基础资料字段查询触发此事件

        /// </summary>

        /// <param name="e"></param>

        public override void BeforeF7Select(BeforeF7SelectEventArgs e)

        {

            base.BeforeF7Select(e);
            int orgId =Convert.ToInt32(this.Context.CurrentOrganizationInfo.ID);

            // 给仓库查询附加过滤条件

            if (e.FieldKey.EqualsIgnoreCase("F_QLTK_MulMaterial") && e.FormId.EqualsIgnoreCase("BD_STOCK"))

            {

                e.ListFilterParameter.Filter = e.ListFilterParameter.Filter.JoinFilterString(" FForbidStatus='A' and FUseOrgId='"+ orgId + "' ");

                return;

            }



            // 给物料查询附加过滤条件

            //if (e.FieldKey.EqualsIgnoreCase("F_QLTK_MulMaterial") && e.FormId.EqualsIgnoreCase("BD_MATERIAL"))

            //{

            //    e.ListFilterParameter.Filter = e.ListFilterParameter.Filter.JoinFilterString(" FMaterialGroup in (select FID from T_BD_MATERIALGROUP where FNUMBER like '02%') ");

            //    return;

            //}

        }



        /// <summary>

        /// 基础资料查询前事件，账表过滤窗体上的过滤条件表格、批量过滤条件表格中的基础资料字段查询触发此事件

        /// </summary>

        /// <param name="e"></param>

        public override void BeforeFilterGridF7Select(BeforeFilterGridF7SelectEventArgs e)

        {

            base.BeforeFilterGridF7Select(e);

            //// 给供应商编码查询附加过滤条件

            //if (e.FieldKey.EqualsIgnoreCase("FSupplierNumber"))

            //{

            //    e.ListFilterParameter.Filter = e.ListFilterParameter.Filter.JoinFilterString(" FNumber like '%SCM%' ");

            //    return;

            //}



            //// 给物料名称查询附加过滤条件

            //if (e.FieldKey.EqualsIgnoreCase("FMaterialName"))

            //{

            //    e.ListFilterParameter.Filter = e.ListFilterParameter.Filter.JoinFilterString(" FName like N'%轴承%' ");

            //    return;

            //}

        }

    }

}
